package gdkm.dao;

import kxc.gdkm.pojo.StudentInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface StudentInfoDAO {

    @Select("select * from student_info where id = #{id}")
    @Results(id = "StudentInfoMap",value = {
            @Result(property = "user", column = "user_id",one = @One(select = "kxc.gdkm.dao.UserDAO.findById"))
    })
    StudentInfo findById(Integer id);

    @Select("select * from student_info")
    @ResultMap("StudentInfoMap")
    List<StudentInfo> findAll();

    @Insert("INSERT INTO student_info " +
            "(user_id, real_name, gender, birthday, id_card, university, major, education, graduation_time, " +
            "political_status, hometown, current_city, job_intention, job_type, salary_expectation, self_introduction ,create_time,update_time) " +
            "VALUES " +
            "(#{userId}, #{realName}, #{gender}, #{birthday}, #{idCard}, #{university}, #{major}, #{education}, #{graduationTime}, " +
            "#{politicalStatus}, #{hometown}, #{currentCity}, #{jobIntention}, #{jobType}, #{salaryExpectation}, #{selfIntroduction},#{createTime},#{updateTime})")
    boolean save(StudentInfo studentInfo);

    @Update("UPDATE student_info " +
            "SET user_id = #{user.id}, real_name = #{realName}, gender = #{gender}, birthday = #{birthday}, id_card = #{idCard}, university = #{university}, " +
            "major = #{major}, education = #{education}, graduation_time = #{graduationTime}, " +
            "political_status = #{politicalStatus}, hometown = #{hometown}, current_city = #{currentCity}, job_intention = #{jobIntention}, " +
            "job_type = #{jobType}, salary_expectation = #{salaryExpectation},update_time = #{updateTime} " +
            "WHERE id = #{id}")
    boolean update(StudentInfo studentInfo);

    @Delete("DELETE FROM student_info WHERE id = #{id}")
    boolean delete(Integer id);

}
